<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>
		选择员工窗口
	</title>
</head>
<e:View id="eView" designProperty="width: 1024px; height: 768px">
	<script type="text/javascript">SkinUtil.getSkin();</script>
	<script type="text/javascript">SkinUtil.getModuleSkin();</script>	
	
	<div id="Invisual Controls" style="display: none;" style="min-height: 40px; background-color: LemonChiffon;" >
		<e:Dataset id="Dataset_User" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="dataset_user" pageSize="30" 
				loadDataCommand="Command_load" allowMultiSelect="true">
			<e:Field name="userId" dataType="string" label="员工号" maxLength="32" />
			<e:Field name="userName" dataType="string" label="员工姓名" maxLength="200" />
			<e:Field name="orgId" dataType="string" label="orgId" maxLength="32" visible="false"/>
			<e:Field name="roleId" dataType="string" label="roleId" maxLength="32"  visible="false"/>
			<e:Field name="orgName" dataType="string" label="所属机构名称" maxLength="100" />
		</e:Dataset>
	 
		
		<e:Command id="Command_load" action="com.longtop.framework.sys.user.web.UserDropdownAction" 
			method="load" showHintInfoOnSuccess="false" onBeforeExecute="cmd_load_onBeforeExecute(command)">
			<e:DatasetInfo name="info" dataset="Dataset_User" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
			<e:Parameter name="orgId" value=""></e:Parameter>
		</e:Command>
		<e:Command id="Command_search" action="com.longtop.framework.sys.user.web.UserDropdownAction" 
			method="search" submitForm="true">
			<e:DatasetInfo name="info" dataset="Dataset_User" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
			<e:Parameter name="orgId" value=""></e:Parameter>
		</e:Command>
		
		<e:LookupDropDown id="LookupDropDown_Org" path="/jsp/framework/sys/org/orgDropdown.jsp"	windowWidth="400" windowHeight="450" 
				autoDropDown="true" fixed="true" onSelect="LookupDropDown_Org_onSelect(dropdown,iframe,text)"  windowCaption="选择部门">
		</e:LookupDropDown>	
		
		<e:Command id="Command_getTeamUser" action="com.longtop.framework.sys.team.web.UserTeamAction"  method="getTeam" submitForm="true" showHintInfoOnSuccess="false" >
			<e:DatasetInfo name="info" dataset="Dataset_TeamUser" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
		</e:Command>
		<e:Command id="Command_getTeamOrg" action="com.longtop.framework.sys.team.web.OrgTeamAction"  method="getTeam" submitForm="true" showHintInfoOnSuccess="false" >
			<e:DatasetInfo name="info" dataset="Dataset_TeamOrg" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
		</e:Command>		
		<e:Dataset id="Dataset_TeamUser" pageSize="-1">
			<e:Field name="userTeamId" dataType="string" label="员工群组ID" />
			<e:Field name="userTeamName" dataType="string" label="群组名称" />
		</e:Dataset>			 					
		<e:Dataset id="Dataset_TeamOrg" pageSize="-1">
			<e:Field name="orgTeamId" dataType="string" label="机构群组ID" />
			<e:Field name="orgTeamName" dataType="string" label="群组名称" />
		</e:Dataset> 			
		<e:DataDropDown dataset="Dataset_TeamUser" id="DataDropDown_TeamUser" autoDropDown="false" fixed="true" showColumnHeader="false"
			codeField="userTeamId" textField="userTeamName" visibleFields="userTeamName" onAfterSelect="DataDropDown_TeamUser_onAfterSelect(dropdown,record,text)">
		</e:DataDropDown>						
		<e:DataDropDown dataset="Dataset_TeamOrg" id="DataDropDown_TeamOrg" autoDropDown="false" fixed="true" showColumnHeader="false"
			codeField="orgTeamId" textField="orgTeamName" visibleFields="orgTeamName" onAfterSelect="DataDropDown_TeamOrg_onAfterSelect(dropdown,record,text)">
		</e:DataDropDown>	
		
		<e:LookupDropDown id="LookupDropDown_Duty" path="/jsp/framework/sys/user/dutyDropdown.jsp?showSelect=true"	windowWidth="400" windowHeight="420" 
			autoDropDown="true" fixed="true" onSelect="LookupDropDown_Duty_onSelect(dropdown,iframe,text)" windowCaption="选择职务">
		</e:LookupDropDown>			
	</div>
<body style="overflow: hidden">
<e:Page id="ePage" action="com.longtop.framework.sys.user.web.UserDropdownAction" style="min-height: 80px; width: 100%; height: 100%;"
	onAfterLoadPage="ePage_onAfterLoadPage()" onBeforeLoadPage="ePage_onBeforeLoadPage()" tag="window">
	<table style="width: 100%;height:100%" border="0" cellpadding="2" cellspacing="2">
		<tbody>
			<tr>
				<td align="left" valign="top">
					<e:Panel id="Panel_query" style="width: 210px;height:100%" caption="查询条件" captionIcon="/images/query_win.gif"
							captionStyle="color:#888888" allowFold="true" showArrowButton="false">
						<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" align="center">
								<tr><td><e:Label id="Label_userId" caption="员工ID："/></td></tr>
								<tr>
									<td><e:Text id="Text_userId" style="width:150px"/></td>
								</tr>
								<tr><td><e:Label id="Label_userName" caption="员工名称："/></td></tr>
								<tr>
									<td><e:Text id="Text_userName" style="width:150px"/></td>
								</tr>
								<tr><td><e:Label id="Label_duty" caption="员工职务："/></td></tr>
								<tr>
									<td><e:Text id="Text_duty" dropDown="LookupDropDown_Duty" style="width:150px"/></td>
								</tr>								
								<tr><td><e:Label id="Label_orgName" caption="所属机构："/></td></tr>
								<tr>
									<td><e:Text id="Text_orgId" dropDown="LookupDropDown_Org" style="width:150px"/></td>
								</tr>
								<tr><td><e:Label id="Label_teamUser" caption="所在员工群组："/></td></tr>
								<tr>
									<td><e:Text id="Text_teamUser" dropDown="DataDropDown_TeamUser" style="width:150px"/></td>
								</tr>	
								<tr><td><e:Label id="Label_teamOrg" caption="所在机构群组："/></td></tr>
								<tr>
									<td><e:Text id="Text_teamOrg" dropDown="DataDropDown_TeamOrg" style="width:150px"/></td>
								</tr>																
								<tr>
									<td align="left">
										<e:Button id="Button_Search" style="height: 22px; width: 70px;;" caption="查询" icon="/images/query.gif" onClick="Button_Search_onClick()"></e:Button>&nbsp;&nbsp;
										<e:Button id="Button_reset" style="height: 22px; width: 70px;;" caption=" 重置" icon="/images/refresh.gif" onClick="Button_reset_onClick()"></e:Button>
									</td>
								</tr>																																																
						</table>
					</e:Panel>
				</td>
				<td valign="top" width="100%">
						<table style="text-align: left; width: 100%;height: 100%" border="0" cellpadding="2" cellspacing="2" align="center">
							<tr>
								<td valign="top">
									<e:Grid id="Grid_Result" style="width: 100%; height:410px;" dataset="Dataset_User" showIndicator="false" showIndex="true" readOnly="true" >					
									</e:Grid>
								</td>
							</tr>
							<tr>
								<td>
									<e:PageNavigator id="PageNavigator_User" dataset="Dataset_User" style="height: 27px;"></e:PageNavigator>
								</td>
							</tr>
							<tr>
								<td align="center" valign="top" height="60">
									<e:Button id="Button_ok" caption="确定" style="width:75" onClick="Button_ok_onClick()" icon="/images/submit.gif" /> &nbsp; 
									<e:Button id="Button_close" caption="关闭" style="width:75" onClick="window.close()" icon="/images/delete.gif" /> &nbsp;
								</td>
							</tr>																
						</table>
				</td>
			</tr>
		</tbody>
    </table>
</e:Page>
</body>
<script type="text/javascript">
	//init
	function ePage_onBeforeLoadPage(){
		var showSelect = "${param.showSelect}";
		//是否需要显示selectBox
		if(showSelect == 'false'){
			Dataset_User.allowMultiSelect=false;
		}
	}
	var orgId;
	var orgName;
	function ePage_onAfterLoadPage(){
		orgId = $J("Text_orgId").getValue();
		orgName = $J("Text_orgId").getDisplayValue();
		
		//加载群组：
		Command_getTeamUser.execute();
		Command_getTeamOrg.execute();
	}
	
	//重置：
	function Button_reset_onClick(){
		$J("Text_userId").setValue("");
		$J("Text_userName").setValue("");
		$J("Text_teamUser").setValue("");
		$J("Text_teamOrg").setValue("");
		$J("Text_duty").setValue("");
		$J("Text_orgId").setValue(orgId,orgName);
		
	}
	
	//选择部门
	function LookupDropDown_Org_onSelect(dropdown,iframe,text){
		var dataset= $J(iframe.Dataset_Org);
    	if(dataset){
	    	var record = dataset.getCurrentRecord();
	    	if(typeof record != "undefined" && record != null){
	       		$J("Text_orgId").setValue(record.getValue("orgId"),record.getValue("orgName"));
	    	}
		}
	}
	
	//翻页
	function cmd_load_onBeforeExecute(command){
		var orgId = $J("Text_orgId").getValue();
		if( !isEmpty(orgId) ) {
			Command_load.parameters.setValue("orgId",orgId);
		}else{
			Command_load.parameters.setValue("orgId","");
		}
	}
	//查询
	function Button_Search_onClick(){
		var orgId = $J("Text_orgId").getValue();
		if( !isEmpty(orgId) ) {
			Command_search.parameters.setValue("orgId",orgId);
		}else{
			Command_search.parameters.setValue("orgId","");
		}	
	    Command_search.execute();
	}
	//确定选择用户：
	function Button_ok_onClick(){
	    var array = new Array();
	    var record = $J('Dataset_User').getFirstRecord();
	    while (record != null){
	        if (record.isSelected){
	            var map = new Map();
	        	var fields = $J('Dataset_User').fields;
	        	for(var i = 0 ; i<fields.length ; i++){
	        		map.put(fields[i].name,record.getValue(fields[i].name));
	        	}
	            array.push(map);
	        }
	        record = record.getNextRecord();
	    }
	    window.returnValue = array.join("|");
	    window.close();
	}
	
	//Text选择职务(支持多选)
	function LookupDropDown_Duty_onSelect(dropdown,iframe,text){
		var dataset = $J(iframe.Dataset_Duty);
		var record;
		var dutyIdStr="";
		var dutyNameStr="";					
		var selectedNodes =  $J(iframe.DataTree_Duty).getSelectedNodes();//选中的节点
		if(selectedNodes == null){// 单选
			record = dataset.getCurrentRecord();
			var dutyId ="'"+record.getValue("dutyId")+"'";
			var dutyName= record.getValue("dutyName");						
			$J("Text_duty").setValue(dutyId,dutyName);//组装DutyList
		}else{
			for(var i=0; i<selectedNodes.length; i++) {
			   record = selectedNodes[i].record;
			   if (record) {
					var dutyId ="'"+record.getValue("dutyId")+"',";
					var dutyName= record.getValue("dutyName")+",";
					dutyIdStr = dutyIdStr+dutyId;		
					dutyNameStr = dutyNameStr+dutyName;						       
			   }
			}	
			dutyIdStr = dutyIdStr.substr(0,dutyIdStr.length-1);
			dutyNameStr = dutyNameStr.substr(0,dutyNameStr.length-1);								
		    $J("Text_duty").setValue(dutyIdStr,dutyNameStr);//组装DutyList
	 	}
	}	
</script>
</e:View>
</html>
